# coding: utf-8
from tortoise import models, fields

from core.base_db import BaseModel


class ZhanApplication(BaseModel):
    APPLICATION_GROUP_NONE = 0
    APPLICATION_GROUP_ROTATION_CHART = 1
    APPLICATION_GROUP_HOT = 2

    title = fields.CharField(max_length=255, null=False, description="标题")
    desc = fields.CharField(max_length=255, description="描述")
    hide = fields.BooleanField(default=False, description="是否隐藏（默认false）")
    image_url = fields.TextField(default="", description="背景图地址")
    page_url = fields.CharField(max_length=255, description="点击跳转页面(没有权限不可进入)")
    application_group = fields.IntField(default=APPLICATION_GROUP_NONE, description="应用分组：轮播图分组，热门分组...")
    icon_url = fields.TextField(default="", description="图标地址")
    created_by = fields.ForeignKeyField(model_name="models.ZhanUser", related_name="created_by_user")
    update_by = fields.ForeignKeyField(model_name="models.ZhanUser", related_name="updated_by_user")

    class Meta:
        table = "zhan_application"


class ZhanSwiper(BaseModel):
    name = fields.CharField(max_length=255, null=False, description="名称")
    autoplay = fields.BooleanField(default=True, description="是否自动切换(默认true)")
    interval = fields.CharField(max_length=255, default=3000, description="滑块自动切换时间间隔（ms）")
    loading = fields.BooleanField(default=False, description="是否加载中(默认false)")
    is_show = fields.BooleanField(default=True, description="是否显示（默认true")

    class Meta:
        table = "zhan_swiper"
